﻿package mortal.game.view.FirstRechargeDay500
{
    import Message.Public.*;
    import mortal.common.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.view.FirstRechargeDay500.rechargeAct11.*;
    import mortal.game.view.copy.QuestionCopy.data.*;
    import mortal.mvc.core.*;

    public class RechargeDayController extends Controller
    {

        public function RechargeDayController()
        {
            return;
        }// end function

        override protected function initServer() : void
        {
            EventUtil.addSelfEvent(EventName.RechargeAct11DayRc200, this.onOpenM, true);
            EventUtil.addNetEvent(ServerCommand.RechargeDouble11ActiveHasGetNum, this.updateAct11Recharg, true);
            EventUtil.addSelfEvent(EventName.RechargeAct11DayRc200GetRw, this.onGetRw, true);
            NetDispatcher.addCmdListener(ServerCommand.NewDayUpdate, this.onDateChange);
            LevelCheckUtil.addInit(this.initHd);
            EventUtil.addNetEvent(ServerCommand.RebateDayChargeInfoBack, this.updateAct11Recharg, true);
            return;
        }// end function

        private function onOpenM(event:DataEvent) : void
        {
            if (!RechargeActive11Day200.isView())
            {
                RechargeActive11Day200.instance.show();
            }
            return;
        }// end function

        private function initHd(param1:Object) : void
        {
            this.checkIcon();
            this.updateIconEffect();
            return;
        }// end function

        private function updateAct11Recharg(param1:Object) : void
        {
            if (RechargeActive11Day200.isView())
            {
                RechargeActive11Day200.instance.updateInfo();
            }
            this.checkIcon();
            this.updateIconEffect();
            return;
        }// end function

        private function checkIcon() : void
        {
            if (RechargeActiveUtil.canShowIcon())
            {
                RechargeActive11Day200Icon.instance.show();
            }
            else if (RechargeActive11Day200Icon.hasInstance())
            {
                RechargeActive11Day200Icon.instance.hide();
            }
            return;
        }// end function

        private function updateIconEffect() : void
        {
            if (RechargeActive11Day200Icon.hasInstance())
            {
                if (RechargeActiveUtil.hasAct11Re200Rw())
                {
                    RechargeActive11Day200Icon.instance.playEffect();
                }
                else
                {
                    RechargeActive11Day200Icon.instance.stopEffect();
                }
            }
            return;
        }// end function

        private function onGetRw(event:DataEvent) : void
        {
            GameProxy.openServerSevenDay.getActiveGiftBag(EActiveType._EActiveTypeDouble11);
            return;
        }// end function

        private function onDateChange(param1:Object) : void
        {
            RechargeActiveUtil.dou11RechargeHasGetNum = 0;
            var _loc_2:* = ClockManager.instance.getDelayDate(1000);
            ClockManager.instance.addDateCall(_loc_2, this.refleshDate);
            return;
        }// end function

        private function refleshDate() : void
        {
            this.updateAct11Recharg(null);
            return;
        }// end function

    }
}
